/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.lm.entity;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Robson Motta
 */
@Entity
@Table(name = "ctrl_perfil")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "CtrlPerfil.findAll", query = "SELECT c FROM CtrlPerfil c"),
    @NamedQuery(name = "CtrlPerfil.findByIdPerfil", query = "SELECT c FROM CtrlPerfil c WHERE c.idPerfil = :idPerfil")})
public class CtrlPerfil implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE)    
    @SequenceGenerator(name = "Ctrl_Perfil_id_perfil_seq", sequenceName = "Ctrl_Perfil_id_perfil_seq", initialValue = 1, allocationSize = 1)
    @Basic(optional = false)
    @Column(name = "id_perfil")
    private Integer idPerfil;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 100)
    @Column(name = "dsc_perfil")
    private String dscPerfil;
    @Column(name = "sts_perfil")
    private Character stsPerfil;
    
    @OneToMany(fetch = FetchType.LAZY, mappedBy = "idPerfil")
    private Collection<CtrlUsuario> ctrlUsuarioCollection;
        
    @OneToMany(fetch = FetchType.EAGER, mappedBy = "ctrlPerfil")
    private Collection<CtrlPerfilAcesso> ctrlPerfilAcessoCollection;
    
    public CtrlPerfil() {
    }

    public CtrlPerfil(Integer idPerfil) {
        this.idPerfil = idPerfil;
    }

    public CtrlPerfil(Integer idPerfil, String dscPerfil) {
        this.idPerfil = idPerfil;
        this.dscPerfil = dscPerfil;
    }

    public Integer getIdPerfil() {
        return idPerfil;
    }

    public void setIdPerfil(Integer idPerfil) {
        this.idPerfil = idPerfil;
    }

    public String getDscPerfil() {
        return dscPerfil;
    }

    public void setDscPerfil(String dscPerfil) {
        this.dscPerfil = dscPerfil;
    }

    public Character getStsPerfil() {
        return stsPerfil;
    }

    public void setStsPerfil(Character stsPerfil) {
        this.stsPerfil = stsPerfil;
    }

    @XmlTransient
    public Collection<CtrlUsuario> getCtrlUsuarioCollection() {
        return ctrlUsuarioCollection;
    }

    public void setCtrlUsuarioCollection(Collection<CtrlUsuario> ctrlUsuarioCollection) {
        this.ctrlUsuarioCollection = ctrlUsuarioCollection;
    }

    @XmlTransient
    public Collection<CtrlPerfilAcesso> getCtrlPerfilAcessoCollection() {
        return ctrlPerfilAcessoCollection;
    }

    public void setCtrlPerfilAcessoCollection(Collection<CtrlPerfilAcesso> ctrlPerfilAcessoCollection) {
        this.ctrlPerfilAcessoCollection = ctrlPerfilAcessoCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idPerfil != null ? idPerfil.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof CtrlPerfil)) {
            return false;
        }
        CtrlPerfil other = (CtrlPerfil) object;
        if ((this.idPerfil == null && other.idPerfil != null) || (this.idPerfil != null && !this.idPerfil.equals(other.idPerfil))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "br.com.lm.entity.CtrlPerfil[ idPerfil=" + idPerfil + " ]";
    }
    
}
